package com.xdxc.utils;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import java.io.IOException;
import java.util.List;
public class CustomSerializer extends JsonSerializer<List<Long>> {

    @Override
    public void serialize(List<Long> value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
        if (value == null) {
            gen.writeNull(); // 如果值为 null，直接写入 null
        } else {
            gen.writeStartArray(); // 开始数组
            for (Long item : value) {
                gen.writeNumber(item); // 写入每个 Long 值
            }
            gen.writeEndArray(); // 结束数组
        }
    }
}